package com.ruoyi.pcj.interfaces.app;

import com.mashuai.utils.toolkit.core.msValidation.annotation.MsCheckObjParams;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.pcj.constant.TipConstant;
import com.ruoyi.pcj.domain.*;
import com.ruoyi.pcj.service.IPcMsgNoticeService;
import com.ruoyi.pcj.service.IPcjAbleService;
import com.ruoyi.pcj.service.IPcjHobbyTypeService;
import com.ruoyi.pcj.service.IPcjTargetService;
import com.ruoyi.pcj.utils.pcj.PcjUtils;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * pcj业务公用接口，
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/common")
public class PcjCommonController {


    private IPcjHobbyTypeService hobbyTypeService;

    private IPcjTargetService targetService;

    private IPcjAbleService ableService;

    private IPcMsgNoticeService msgNoticeService;


    /**
     * 获取系统配置
     *
     * @param params {code:"编码"}
     **/
    @MsCheckObjParams(keys = "code", message = TipConstant.NO_PARAMS)
    @PostMapping("/getConfig")
    public AjaxResult getConfig(@RequestBody Map<String, Object> params) {
        PcjDefConfig config = PcjUtils.getConfig(MapUtils.getString(params, "code"));
        return AjaxResult.ok(config);
    }

    /**
     * 获取所有的兴趣类型与兴趣
     */
    @PostMapping("/getHobbyData")
    public AjaxResult getHobbyData() {
        List<PcjHobbyType> result = hobbyTypeService.getHobbyData();
        return AjaxResult.ok(result);
    }

    /**
     * 获取所有的目标
     */
    @PostMapping("/getTargetData")
    public AjaxResult getTargetData() {
        List<PcjTarget> result = targetService.getTargetData();
        return AjaxResult.ok(result);
    }

    /**
     * 获取所有的特长
     */
    @PostMapping("/getAbleData")
    public AjaxResult getAbleData() {
        List<PcjAble> result = ableService.getAbleData();
        return AjaxResult.ok(result);
    }


    /**
     * 获取用户通知信息
     *
     * @return
     */
    @PostMapping("/getUserMsgNotice")
    public AjaxResult getUserMsgNotice() {
        List<PcjMsgNotice> msgNoticeData = msgNoticeService.getMsgNoticeData();
        return AjaxResult.ok(msgNoticeData);
    }
}
